from flask import Flask, request, render_template, redirect, url_for
app = Flask(__name__)

# This is needed so it works with uWSGI.
import misc, sys
db = misc.select_db(sys.argv)

@app.route("/")
def root():
    return redirect('static/sagealeph.html')
    #return render_template('root.html')

@app.route("/execute")
def execute():
    return db.execute(request.values['input'])

@app.route("/get")
def get():
    return db.get_json(request.values['id'])

if __name__ == "__main__":
    db = misc.select_db(sys.argv)
    app.run(debug=True)
